//
//  AKLocalServer.h
//  AKLocalServer
//
//  Created by Yun Qing Teng on 11/12/06.
//  Copyright 2006 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>

#define READ_BUFFER_SIZE 4096
#define MAX_BUFFER_SIZE 256

typedef struct UserInfo {
	char username[9];
	int fd;
	
	// what the length byt says we should get
	unsigned int currentMessageSize;
	
	// what we have read (not including length)
	int bytesRead;
	unichar buffer[READ_BUFFER_SIZE];
};

@interface AKLocalServer : NSObject {
	NSNetService * netService;
    int listeningSocket;
	struct UserInfo user;
	fd_set userfd;
	uint16_t chosenPort;
	id delegate;
}

- (void)publishServiceWithName:(NSString *)aName;
- (void)startANewTurn;
- (void)sendMessage:(NSString *)aMessage;
- (void)sendNewMoveWithChessIndex:(unsigned)aIndex step:(unsigned)newStep;
- (void)setDelegate:(id)aDelegate;
- (void)acceptConnection:(id)anObject;
- (void)readData:(id)anObject;
@end
